module mod_database

   use iso_fortran_env, only: dp => real64

contains

   function get_element_molar_mass(name) result(Mr)

      character(len=*), intent(in) :: name
      real(dp) :: Mr

      select case (name)
      case ('H')
         Mr = 1.00794_dp
      case ('He')
         Mr = 4.00260_dp
      case ('Li')
         Mr = 6.93896_dp
      case ('Be')
         Mr = 9.01218_dp
      case ('B')
         Mr = 10.806_dp
      case ('C')
         Mr = 12.0107_dp
      case ('N')
         Mr = 14.0067_dp
      case ('O')
         Mr = 15.9994_dp
      case ('F')
         Mr = 18.9984_dp
      case ('Ne')
         Mr = 20.1797_dp
      case ('Na')
         Mr = 22.9898_dp
      case ('Mg')
         Mr = 24.305_dp
      case ('Al')
         Mr = 26.9815_dp
      case ('Si')
         Mr = 28.0855_dp
      case ('P')
         Mr = 30.9738_dp
      case ('S')
         Mr = 32.065_dp
      case ('Cl')
         Mr = 35.453_dp
      case ('Ar')
         Mr = 39.948_dp
      case ('K')
         Mr = 39.0983_dp
      case ('Ca')
         Mr = 40.078_dp
      case ('Sc')
         Mr = 44.9559_dp
      case default
         stop 'unknown element'
      end select

   end function get_element_molar_mass

   pure function TArray(T, n) result(array)

      real(dp), intent(in) :: T
      integer, intent(in) :: n
      real(dp), allocatable :: array(:)

      integer :: i

      array = [(T**i, i=0, n - 1)]

   end function Tarray

end module mod_database
